<?php get_header(); $boke8 = get_option('leonhere');?>
<main class="wrapper">
	<div class="inner">
		<?php 
			if(!empty($boke8['news'])){	
				$news = $boke8['news'];	
				$term = get_term($news,'topics');
				$getposts = get_posts(array(
					'numberposts' => '12',
					'post_type' => 'news_type',	
					'post_status' => 'publish',
					'tax_query'=>array(
						array(
							'taxonomy'=>'topics',
							'terms'=>$news
							)
						),
					)
				);
				if($getposts):
		?>
		<section class="hmtop">
			<h2>热点资讯</h2>
			<span class="more"><a href="<?php echo get_term_link(intval($news));?>" title="<?php echo $term->name;?>">更多</a></span>			
			<div class="right">
				<div id="hmtop">
					<?php foreach($getposts as $post):?>
					<div class="item">
						<a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title();?>"><?php the_title();?></a>
					</div>
					<?php wp_reset_postdata(); endforeach;?>
				</div>
			</div>
		</section>
		<?php endif;  } ?>
		<?php
			$sticky = get_option('sticky_posts');			
			query_posts( array('showposts'=>'8', 'post__in' => $sticky, 'ignore_sticky_posts' => 1,'post_status' => 'publish' ) );
			if (have_posts()) :		
		?>
		<section class="appbox">
			<div class="boxtop">
				<h2>小编推荐</h2>
			</div>
			<div class="applist">
				<ul>
					<?php while (have_posts()) : the_post();?>
					<li>
						<div class="box">
							<figure class="icon">
								<a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title(); ?>">
									<img src="<?php get_template_part('functions/thumbnail');?>" alt="<?php the_title(); ?>"/>
								</a>
							</figure>
							<div class="info">
								<h3><a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
								<?php if(get_post_meta($post->ID, "size", true)){?>
								<div class="meta">
									<span>大小：<?php echo get_post_meta($post->ID, "size", true);?></span>
								</div>
								<?php } ?>
								<div class="support">
									<?php if(get_post_meta($post->ID, "android", true)){?>
									<span class="and"><i></i></span>
									<?php } ?>
									<?php if(get_post_meta($post->ID, "ios", true)){?>
									<span class="ios"><i></i></span>
									<?php } ?>
								</div>
							</div>
							<div class="clear"></div>
							<div class="intro">
								<em>简介：</em><?php echo wp_trim_words($post->post_content, 35, '...');?>
							</div>						
						</div>
					</li>
					<?php endwhile;?>
				</ul>
			</div>
		</section>
		<?php endif; wp_reset_query();?>
		<?php if(!empty($boke8['listad'])){?>
		<div class="hmdiv">
			<?php echo htmlspecialchars_decode($boke8['listad']);?>
		</div>
		<?php } ?>
		<?php 
		if(!empty($boke8['app']) && !empty($boke8['appnum'])){
		  $appArray = $boke8['app'];
		  $appnum = $boke8['appnum'];
		  sort($appArray);
		  foreach($appArray as $app){
			query_posts('&cat='.$app.'&post_status=publish&showposts='.$appnum);
		?>
		<section class="appbox">
			<div class="boxtop">
				<h2><?php echo get_cat_name($app);?></h2>
				<span><a href="<?php echo get_category_link($app); ?>" title="<?php echo get_cat_name($app);?>">更多 &gt;</a></span>
			</div>
			<div class="applist">
				<ul>
					<?php while (have_posts()) : the_post(); ?>
					<li>
						<div class="box">
							<figure class="icon">
								<a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title(); ?>">
									<img src="<?php get_template_part('functions/thumbnail');?>" alt="<?php the_title(); ?>"/>
								</a>
							</figure>
							<div class="info">
								<h3><a href="<?php the_permalink(); ?>" target="_blank" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
								<?php if(get_post_meta($post->ID, "size", true)){?>
								<div class="meta">
									<span>大小：<?php echo get_post_meta($post->ID, "size", true);?></span>
								</div>
								<?php } ?>
								<div class="support">
									<?php if(get_post_meta($post->ID, "android", true)){?>
									<span class="and"><i></i></span>
									<?php } ?>
									<?php if(get_post_meta($post->ID, "ios", true)){?>
									<span class="ios"><i></i></span>
									<?php } ?>
								</div>
							</div>
							<div class="clear"></div>
							<div class="intro">
								<em>简介：</em><?php echo wp_trim_words($post->post_content, 35, '...');?>
							</div>						
						</div>
					</li>
					<?php endwhile;?>					
				</ul>
			</div>
		</section>
		<?php wp_reset_query();} }?>
		<section class="hmlinks">
			<div class="boxtop">
				<h2>友情链接</h2>
			</div>
			<ul>
				<?php wp_list_bookmarks('show_description=0&show_images=0&title_li=&categorize=0');?>
			</ul>
		</section>
	</div>
</main>
<?php get_footer();?>